package com.session1;

import java.awt.Button;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class JAplletDemo extends JApplet implements ActionListener {
	private JButton b ;
	@Override
	public void init() {
		this.setBackground(Color.blue);
		JPanel p = new JPanel();
		p.add(new JButton("Button 1"));
		p.add(new JButton("Button 2"));
		p.add(new JButton("Button 3"));
		p.add(new JButton("Button 4"));
		p.add(new JCheckBox("Chon"));
		
		ImageIcon icon = new ImageIcon("D:/DEMO/DCJDemo/src/com/session1/svg2raster.png");
		JLabel lbName = new JLabel("UserName");
		lbName.setIcon(icon);
		p.add(lbName);
		
		this.b = new JButton("Login");
		p.add(b);
		
		p.setBorder(BorderFactory.createTitledBorder("Name"));
		this.getContentPane().add(p);
		// dang ky su kien
		b.addActionListener(this);
		super.init();
	}
	public static void main(String[] args) {
		JAplletDemo ap = new JAplletDemo();
		ap.start();
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == this.b){
			JOptionPane.showMessageDialog(this, "Thank you");
		}
	}
}
